import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '@/layouts/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'HomeView',
    title: '主页',
    component: HomeView,
    children: [
      {
        path: '/firstmapboxMap',
        name: 'FirstmapboxMap',
        title: 'mapbox地图',
        component: () => import('../views/FirstmapboxMap.vue')
      },
      {
        path: '/circles',
        name: 'Circles',
        title: '地震波扩散效果',
        component: () => import('../views/Circles.vue')
      },
      {
        path: '/mapEvent',
        name: 'MapEvent',
        title: '地图事件',
        component: () => import('../views/MapEvent.vue')
      },
      {
        path: '/vectorTileLayer',
        name: 'VectorTileLayer',
        title: '矢量切片',
        component: () => import('../views/VectorTileLayer.vue')
      },
      {
        path: '/customLayer',
        name: 'CustomLayer',
        title: '自定义图层',
        component: () => import('../views/CustomLayer.vue')
      },
      {
        path: '/mapboxLumagl',
        name: 'MapboxLumagl',
        title: 'lumagl画三角形',
        component: () => import('../views/VUE2Lumagl.vue')
      },
      {
        path: '/lumaGLSpatial',
        name: 'LumaGLSpatial',
        title: 'lumagl地图',
        component: () => import('../views/LumaGLSpatial.vue')
      },
      {
        path: '/geojson',
        name: 'Geojson',
        title: 'geojson图层',
        component: () => import('../views/GeojsonLayer.vue')
      },
      {
        path: '/popup',
        name: 'Popup',
        title: '弹窗',
        component: () => import('../views/popup.vue')
      },
      {
        path: '/realTime',
        name: 'RealTime',
        title: '数据实时更新',
        component: () => import('../views/RealTimeData.vue')
      },
      {
        path: '/overLap',
        name: 'OverLap',
        title: '点位重叠检测',
        component: () => import('../views/OverLap.vue')
      },
      {
        path: '/dataJoin',
        name: 'DataJoin',
        title: 'data-join',
        component: () => import('../views/DataJoin.vue')
      },
      {
        path: '/vectorJoin',
        name: 'VectorJOIN',
        title: 'vector-join',
        component: () => import('../views/VectorJOIN.vue')
      },
      {
        path: '/dataTansforms',
        name: 'DataTansforms',
        title: '数据转换',
        component: () => import('../views/DataTansforms.vue')
      },
      {
        path: '/drawTool',
        name: 'DrawTool',
        title: '绘制工具',
        component: () => import('../views/DrawTool.vue')
      }, //
      {
        path: '/layerIndex',
        name: 'LayerIndex',
        title: '分级显示',
        component: () => import('../views/LayerIndex.vue')
      },
      {
        path: '/polygonHighLight',
        name: 'PolygonHighLight',
        title: '拾取高亮显示',
        component: () => import('../views/polygonHighLight.vue')
      },
      {
        path: '/layerAttributeSet',
        name: 'LayerAttributeSet',
        title: '图层属性设置和beforeId',
        component: () => import('../views/LayerAttributeSet.vue')
      }, //
      {
        path: '/richTextLabels',
        name: 'RichTextLabels',
        title: '标注',
        component: () => import('../views/RichTextLabels.vue')
      }, //
      {
        path: '/markersLayer',
        name: 'MarkersLayer',
        title: 'marker图层',
        component: () => import('../views/MarkersLayer.vue')
      }, //
      {
        path: '/canvasImg',
        name: 'CanvasImg',
        title: '绘制canvas图标展示',
        component: () => import('../views/CanvasImg.vue')
      },
      { //
        path: '/customControl',
        name: 'CustomControl',
        title: '自定义控件',
        component: () => import('../views/CustomControl.vue')
      },
      {
        path: '/extrusionHeight',
        name: 'ExtrusionHeight',
        title: '拉伸高度面图层',
        component: () => import('../views/ExtrusionHeight.vue')
      },
    ]
  }

]

// 解决路由重复点击报错
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return routerPush.call(this, location).catch((err) => err)
}
const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
